
////////////////////////////////////////////////////////////
//	File:		"TaskThread.cpp"
//	Author:		[A ] Anthony  Lundquist
//	Created:	[A ] March 14, 2010
//	Purpose:	the threads that tasks run on
////////////////////////////////////////////////////////////

#include "TaskThread.h"

#include "AL_Task.h"

/* Data Members */

/* Constructors */

TaskThread::TaskThread() : AL_Thread(), m_bJustFinished(false)
{

}

/* Accessors */

/* Mutators */

/* Other Functions */
void TaskThread::Init()
{
	Pause();
	m_pTask = NULL;
	m_bJustFinished = false;
}

void TaskThread::Shutdown()
{
	if(m_pTask)
		delete m_pTask;

	m_pTask = NULL;
}

void TaskThread::ThreadMain()
{
	// run the task
	// TODO: throw the timer through there, not 0.0f
	m_pTask->RunTask(0.0f);

	// pause the thread so it can wait for the next task
	Pause();

	m_bJustFinished = true;
}

void TaskThread::FinishTask()
{
	m_pTask->FinishTask();

	Shutdown();
}

bool TaskThread::GetJustFinished(void)
{
	bool rValue = m_bJustFinished;
	m_bJustFinished = false;

	return rValue;
}

/* Destructor */

TaskThread::~TaskThread()
{

}

/* Protected Functions */

/* Private Functions */

